package cc.customer.utils;

import cc.customer.common.domain.ResponseBo;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.dingtalk.api.request.OapiMessageCorpconversationAsyncsendV2Request;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 创建时间：2018年6月1日 下午2:52:43
 * 项目名称：taskmanage
 * @author yhsh
 * @version 1.0
 * @since JDK 1.7.0_21 
 * 类说明：   通知类的定义的模板
 */
public class MessageTemplate {

	/**发送企业全部人员的通知***/
	public  static ResponseBo sendAllCompnyMsg(List<OapiMessageCorpconversationAsyncsendV2Request.Form> array, String userid, String content,String type,String exUuid){
		String token = DingDingMessageUtil.getToken(type);
		OapiMessageCorpconversationAsyncsendV2Request.OA jsonObject = paraseMsgInfo(array,content);
		return DingDingMessageUtil.sendNewMsg(token,userid,jsonObject,type,exUuid);
	}


	private static OapiMessageCorpconversationAsyncsendV2Request.OA paraseMsgInfo(List<OapiMessageCorpconversationAsyncsendV2Request.Form> array,String content){

		OapiMessageCorpconversationAsyncsendV2Request.OA oa = new OapiMessageCorpconversationAsyncsendV2Request.OA();
		oa.setMessageUrl("http://192.168.2.202:8088/customer/");
		/**oa 的head**/
		OapiMessageCorpconversationAsyncsendV2Request.Head head = new OapiMessageCorpconversationAsyncsendV2Request.Head();
		head.setBgcolor("FFBBBBBB");
		head.setText("新里程客户系统");
		oa.setHead(head);
		/**body**/
		OapiMessageCorpconversationAsyncsendV2Request.Body body = new OapiMessageCorpconversationAsyncsendV2Request.Body();
		body.setTitle("推广资源信息");

		Map<String,String> map3 = new HashMap<>();
		map3.put("key","消息编号: ");
		map3.put("value",System.currentTimeMillis()+"");
		/*if (array==null){ array = new JSONArray();
			array.add(map3);
		}*/
		body.setForm(array);
		body.setContent(content);
		body.setAuthor("新里程客户系统");
		//body.put("image","https://cms.xlcwx.com:8443/customer/img/xlc.png");
		oa.setBody(body);
		return oa;

	}


}
